<--- %%NOBANNER%% --> lastcell.sas
 BackForward

/*-------------------<---Start of Description-->---------------------\
| Goto the last cell of the last table;                              |
|---------------------<---End of Description-->----------------------|
|--------------------------------------------------------------------|
|------------<---Start of Files or Arguments Needed-->---------------|
| Argument:                                                          |
|    bmark: the name of the table to be deleted;                     |
|           isn't necessary; default is the current table;           |
|    wordref: you can specify window reference, default if "wordsys";|
| Note: the wordref must be the 2nd paramter;                        |
| Note: space will be read as a part of the book mark; if no bookmark|
| is entered, then assume the cursor is in a table, so delete the    |
| current table.                                                     |
|-------------<---End of Files or Arguments Needed-->----------------|
|--------------------------------------------------------------------|
|------------------<---Start of Files Created-->---------------------|
| Example: %lastcell('t1');                                          |
| Usage:   %lastcell(bmark,wordref);                                 |
\-------------------<---End of Files Created-->---------------------*/
%macro lastcell/parmbuff;
/*--------------------------------------------\
| Author:  Duo Zhou;                          |
| Created: 6-27-2001 9:55pm;                  |
| Purpose: Delete a table;                    |
\--------------------------------------------*/
%local bookmark;
%let bookmark=%qscan(&syspbuff,1,%str(,()''""));
%let fref=;%let wsid=0;
%if %words(&syspbuff, dlm=%quote(,()))>1 %then %let fref=%qscan(&syspbuff,-1,%str(,()''""= ));
%else %let fref=wordsys;
%if (%quote(&bookmark) ne) %then %do;
  %gotobmark("&bookmark");
%end;
%if (&fref ne ) %then %let wsid=%sysfunc(fopen(&fref,o,132,e));
%if &wsid %then %do;
   %let rc=%sysfunc(fclose(&wsid));
   data _null_;
      file &fref lrecl=2000;
      put '[TableSelectTable]';
      put '[EndOfColumn]'; put '[EndOfColumn]'; 
      put '[EndOfRow]'; put '[EndOfRow]';
      put '[TableSelectTable]'; put '[EndOfLine]';
   run;
%end;
%else %put ==> Alert! Incorrect window reference "&fref", or window "&fref" isn%str(%')t open.;
%mend lastcell;